package org.jetlinks.community.device.service;

import org.jetlinks.community.device.entity.ProtocolSupportEntity;
import org.jetlinks.community.protocol.ProtocolSupportInfoLoader;
import org.jetlinks.supports.protocol.management.ProtocolSupportDefinition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;

/**
 * The type Default protocol support info loader.
 *
 * @author tablesheep
 */
@Component
public class DefaultProtocolSupportInfoLoader implements ProtocolSupportInfoLoader {

    @Autowired
    private LocalProtocolSupportService service;

    @Override
    public Flux<ProtocolSupportDefinition> loadAll() {
        return service.createQuery().fetch().map(ProtocolSupportEntity::toDefinition);
    }
}
